package ascript
{
	//#########################
	// Header Includes
	//#########################
	import flash.events.Event;
	import flash.media.Sound;
	import ascript.utilities.DataMovie;
	import ascript.utilities.Point;
	import ascript.utilities.SoundQueued;
	import flash.utils.Dictionary;
	import starling.display.Image;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;
	import starling.text.BitmapFont;
	import starling.text.TextField;
	import starling.display.MovieClip;
	
	//#########################
	// Class Declaration
	//#########################
	public class GameAssets
	{
		//=========================
		// Variables
		//=========================	
		private static var assetList:Dictionary = new Dictionary();
		
		//=========================
		// XML
		//=========================
		[Embed( source='../assets/xml/L1.xml', mimeType='application/octet-stream' )]
		private static var XMLL1:Class;
		[Embed( source='../assets/xml/UIMainMenu.xml', mimeType='application/octet-stream' )]
		private static var XMLUIMainMenu:Class;
		[Embed( source='../assets/xml/UIIngame.xml', mimeType='application/octet-stream' )]
		private static var XMLUIIngame:Class;
		[Embed( source='../assets/xml/Archetypes.xml', mimeType='application/octet-stream' )]
		private static var XMLArchetypes:Class;
		[Embed( source='../assets/images/Sheet1.xml', mimeType='application/octet-stream' )]
		private static var XMLAtlasSheet1:Class;
		[Embed( source='../assets/images/Sheet2.xml', mimeType='application/octet-stream' )]
		private static var XMLAtlasSheet2:Class;
		[Embed( source='../assets/images/Font_Komika.fnt', mimeType='application/octet-stream' )]
		private static var XMLFontKomika:Class;
			
		//=========================
		// Sound
		//=========================
		[Embed( source='../assets/sound/Ambient_L1.mp3' )]
		private static var soundAmbientL1:Class;
		[Embed( source='../assets/sound/Effect_PillUse.mp3' )]
		private static var soundEffectPillUse:Class;
		[Embed( source='../assets/sound/Effect_Heart_Slow.mp3' )]
		private static var soundEffectHeartSlow:Class;
		[Embed( source='../assets/sound/Effect_Heart_Medium.mp3' )]
		private static var soundEffectHeartMedium:Class;
		[Embed( source='../assets/sound/Effect_Heart_Fast.mp3' )]
		private static var soundEffectHeartFast:Class;
		
		//=========================
		// Font
		//=========================
		[Embed( source='../assets/images/Font_Komika.png' )]
		private static var fontKomika:Class;
		
		//=========================
		// Images
		//=========================
		// Atlas
		[Embed( source='../assets/images/Sheet1.png' )]
		private static var imageAtlasSheet1:Class;
		[Embed( source='../assets/images/Sheet2.png' )]
		private static var imageAtlasSheet2:Class;
		
		// Level 1 BG
		[Embed( source='../assets/images/GrassTileOne.png' )]
		private static var GrassTile:Class;
		[Embed( source='../assets/images/sad.png' )]
		private static var SadrockTile:Class;		
		[Embed( source='../assets/images/WalkwayTile.png' )]
		private static var WalkwayTile:Class;
		
		// UI Mask
		[Embed( source='../assets/images/UIMaskInner.png' )]
		private static var imageUIMaskInner:Class;
		[Embed( source='../assets/images/UIMaskOuter.png' )]
		private static var imageUIMaskOuter:Class;
		
		//=========================
		// Initialization
		//=========================	
		public function GameAssets():void
		{
			// XML Data
			assetList[ "XMLUIMainMenu" ] = new XML( new XMLUIMainMenu() );
			assetList[ "XMLUIIngame" ] = new XML( new XMLUIIngame() );
			assetList[ "XMLArchetypes" ] = new XML( new XMLArchetypes() );
			
			assetList[ "XMLLevels" ] = new Vector.<XML>;
			assetList[ "XMLLevels" ].push( new XML( new XMLL0() ) );
			assetList[ "XMLLevels" ].push( new XML( new XMLL1() ) );
			
			// Add Atlases
			assetList[ "AtlasSheet1" ] = new TextureAtlas( Texture.fromBitmap( new imageAtlasSheet1() ), XML( new XMLAtlasSheet1() ) );
			assetList[ "AtlasSheet2" ] = new TextureAtlas( Texture.fromBitmap( new imageAtlasSheet2() ), XML( new XMLAtlasSheet2() ) );
			
			// Add Font
			TextField.registerBitmapFont( new BitmapFont( Texture.fromBitmap( new fontKomika() ),XML( new XMLFontKomika() ) ) );
			
			// Add Textures
			assetList[ "TextureUIMaskOuter" ] = Texture.fromBitmap( new imageUIMaskOuter() );
			assetList[ "TextureUIMaskInner" ] = Texture.fromBitmap( new imageUIMaskInner() );
			assetList[ "TextureBGGrass" ] = Texture.fromBitmap( new GrassTile() );	
			assetList[ "TextureBGSadrock" ] = Texture.fromBitmap( new SadrockTile() );	
			assetList[ "TextureBGWalkway" ] = Texture.fromBitmap( new WalkwayTile() );	
			assetList[ "TextureUIPill" ] = assetList[ "AtlasSheet1" ].getTexture( "UI_Pill" );
			assetList[ "TextureBottle" ] = assetList[ "AtlasSheet1" ].getTexture( "PillBottle" );
			assetList[ "TestRock" ] = assetList[ "AtlasSheet1" ].getTexture( "SadRock" );
			assetList[ "Test" ] = assetList[ "AtlasSheet1" ].getTexture( "Test" );
						
			// Add Movies
			assetList[ "MovieUIHeart" ] = new Vector.<DataMovie>;
			assetList[ "MovieUIHeart" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "Heart_Idle" ), 1 ) ); 
			assetList[ "MovieUIHeart" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "HeartStartled" ), 6 ) ); 
			assetList[ "MovieUIHeart" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "HeartMildScare" ), 6 ) );
			assetList[ "MovieUIHeart" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "HeartFreakout" ), 10 ) );
			assetList[ "MoviePlayer" ] = new Vector.<DataMovie>;
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "PlayerAnimRight" ), 8 ) ); // 0 right
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "PlayerAnimBack" ), 8 ) ); // 1 top
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "PlayerAnimFront" ), 8 ) ); // 2 bottom
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "PlayerAnimRightIdle" ), 5 ) ); // 3 right idle
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "PlayerAnimBackIdle" ), 5 ) ); // 4 top idle
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "PlayerAnimBackIdle" ), 5 ) ); // 5 bottom idle
			assetList[ "MoviePlayer" ].push( new DataMovie( assetList[ "AtlasSheet1" ].getTextures( "willardCry" ), 5 ) ); // 6 death
			assetList[ "MovieMonster" ] = new Vector.<DataMovie>;
			assetList[ "MovieMonster" ].push( new DataMovie( assetList[ "AtlasSheet2" ].getTextures( "MonsterWalkHorizontal" ), 25 ) ); // 0 right
			assetList[ "MovieMonster" ].push( new DataMovie( assetList[ "AtlasSheet2" ].getTextures( "MonsterBack" ), 15 ) ); // 1 top
			assetList[ "MovieMonster" ].push( new DataMovie( assetList[ "AtlasSheet2" ].getTextures( "MonsterFront" ), 15 ) ); // 2 bottom
		}
		
		//=========================
		// Members
		//=========================
		public static function getAsset( tWhat:String ):*
		{
			return assetList[ tWhat ];
		}
	}
}